import { defineStore } from 'pinia'

interface defaultState {
  firstName: string
}
// Create a new store instance.
const useDefaultStore = defineStore({
  id: 'index',
  state: (): defaultState => {
    return {
      firstName: 'Alpha'
    }
  },
  actions: {
    // 设置Name
    setUpdateName(name: string) {
      if (!name) return false
      this.firstName = name
    }
  },
  getters: {
    // 获取值
    getFullName(): string {
      const lastName = 'Vue'
      return this.firstName ? `${lastName} ${this.firstName}` : lastName
    }
  }
})

export default useDefaultStore
